package com.neuedu.javase.thread;

/***
 * 项目名称:  MyJavaSE 
 * 包：  com.neuedu.javase.thread 
 * date:   2025/11/6   10:53  
 * 描述:  
 *  @author : 张金山
 *  作者博客:   https://blog.fulfill.com.cn
 */
public class MyRunnable extends  Object  implements Runnable{
    private String name ;
    private long aliveTime = 0;

    public MyRunnable(String name) {
        this.name = name;
    }

    public MyRunnable(String name, long aliveTime) {
        this.name = name;
        this.aliveTime = aliveTime;
    }

    @Override
    public void run() {
        long index = 0;

        while (true){
            if(index >aliveTime){
                break;
            }

            System.out.println(this.name+ "   线程正在执行" +(index++));

            //休息
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        }
    }
}
